package com.goods.controller.business;

import com.goods.business.service.SupplierService;
import com.goods.common.model.business.ParamModel;
import com.goods.common.model.business.Supplier;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.ConsumerVO;
import com.goods.common.vo.business.SupplierVO;
import com.goods.common.vo.system.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: 赵勇镔
 * @Time: 2021/6/8 11:41
 * @Description:
 */

//xhr.js?b50d:178 GET http://www.localhost:8989/business/supplier/findSupplierList?pageNum=1&pageSize=10&name= 404
@Api(tags = "业务模块-物资来源")
@RestController
@RequestMapping("/business/supplier")
public class SupplierController {

    @Autowired
    private SupplierService supplierService;


    @ApiOperation(value = "物资来源", notes = "物资来源展示")
    @GetMapping("/findSupplierList")
    public ResponseBean<PageVO<SupplierVO>> findSupplierList(@ModelAttribute ParamModel paramModel){
        PageVO<SupplierVO> pageVOs = supplierService.findSupplierList(paramModel);

        return ResponseBean.success(pageVOs);
    }


    @ApiOperation(value = "物资来源", notes = "物资来源新增")
    @PostMapping("/add")
    public ResponseBean add(@RequestBody  SupplierVO supplierVO){
        supplierService.add(supplierVO);

        return ResponseBean.success();
    }


    @ApiOperation(value = "物资来源修改", notes = "数据回显")
    @GetMapping("/edit/{id}")
    public ResponseBean<Supplier> edit(@PathVariable  Long id){
        Supplier supplier = supplierService.edit(id);
        return ResponseBean.success(supplier);
    }


    @ApiOperation(value = "物资来源修改", notes = "数据保存")
    @PutMapping("/update/{id}")
    public ResponseBean update(@PathVariable  Long id,@RequestBody SupplierVO supplierVO){
        supplierService.update(id,supplierVO);
        return ResponseBean.success();
    }

    @ApiOperation(value = "物资来源删除", notes = "删除信息")
    @DeleteMapping("/delete/{id}")
    public ResponseBean delete(@PathVariable  Long id){
        supplierService.delete(id);
        return ResponseBean.success();
    }

    @ApiOperation(value = "物资来源", notes = "物资来源展示不分页")
    @GetMapping("/findAll")
    public ResponseBean<List<SupplierVO>> findAll(){
        List<SupplierVO> SupplierVOS = supplierService.findAll();
        return ResponseBean.success(SupplierVOS);
    }





}
